﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 设计模式.前端控制器模式
{
    public class FrontController
    {
        private Dispatcher dispatcher;
        public FrontController()
        {
            dispatcher = new();
        }

        public bool IsAuthentiUser()
        {
            Console.WriteLine("User is authenticated successfully");
            return true;
        }

        public void TrackRequest(string request)
        {
            Console.WriteLine("Page requested:" + request);
        }

        public void DispatchRequest(string request)
        {
            TrackRequest(request);
            if (IsAuthentiUser())
            {
                dispatcher.Dispatch(request);
            }
        }
    }
}
